from locust import HttpUser,task
from locust.clients import LocustResponse

from apps.testCases.goods.items.DetailCase import *


class TestUser(HttpUser):

    min_wait = 5 * 1000
    max_wait = 10 * 1000


    @task
    def getGoodsDetail(self):
        requestInfo:RequestInfo = DetailCase.detailUsingGET(self.host)
        response:LocustResponse
        with self.client.request(requestInfo.request_method,requestInfo.request_path,
                            data=requestInfo.request_body,params=requestInfo.request_params,
                            catch_response =True
                            ) as response:
            if response.status_code == 200:
                response.success()
            else:
                response.failure("Request failed with status code: %s" % response.status_code)
